{include file="public/top"}
<article class="page-container">
    <form id="form-qbank-add" class="form-horizontal" role="form" action="{:url('admin/examType/add')}" method="post"
          enctype="multipart/form-data">
        {:token()}

        <div class="row cl" style="padding-top:20px;margin-left:-40px;">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>试卷名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input class="input-text radius" type="text" name="qname" value="">
            </div>
        </div>
        <div class="row cl" style="padding-top:20px;margin-left:-40px;">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input class="input-text radius" type="text" name="time" placeholder="秒" value="">
            </div>
        </div>
        <div class="row cl" style="padding-top:20px;margin-left:-40px;">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所属题库：</label>
            <div class="formControls col-xs-8 col-sm-9">
            <span class="select-box" style="width:150px;">
                <select name="qbank_id" class="select" size="1">
                    {volist name="bankList" id="cate"}
                        <option value="{$cate.bid}" >{$cate.bank_name}</option>
                    {/volist}
                </select>
            </span>
            </div>
        </div>
        {volist name="typeList" id="type"}
        <div class="row cl" style="padding-top:20px;margin-left:-40px;">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>{$type.type_name}：</label>
            <div class="formControls col-xs-8 col-sm-9">
            <span class="select-box" style="width:150px;">
                <select name="questions_q{$type.qtype}" class="select" size="1">
                    <option value='0' selected>---</option>";

                    {for start="1" end="20" step="1" name="i"}

                        <option value="{$i}">{$i}</option>
                    {/for}
                </select>

                <input name="score_q{$type.qtype}" class="input-text radius" type="text" placeholder="题目分值"
                       value="">

            </span>
            </div>
        </div>
        {/volist}

        <div class="row cl" style="padding-top:20px;margin-left:40px;">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__ADMIN__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__ADMIN__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__ADMIN__/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script type="text/javascript" src="__ADMIN__/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="__ADMIN__/lib/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="__ADMIN__/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-question-add").validate({
            rules: {
                content: {
                    required: true,
                    minlength: 1

                },
                qtype_id: {
                    required: true,
                },
                phone: {
                    required: true,
                    isPhone: true,
                },
                email: {
                    required: true,
                    email: true,
                },
                adminRole: {
                    required: true,
                },
            },
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "xxxxxxx",
                    success: function (data) {
                        layer.msg('添加成功!', {icon: 1, time: 1000});
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                        layer.msg('error!', {icon: 1, time: 1000});
                    }
                });
                var index = parent.layer.getFrameIndex(window.name);
                parent.$('.btn-refresh').click();
                parent.layer.close(index);
            }
        });
    });
</script>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    UE.getEditor('content', {initialFrameWidth: 600, initialFrameHeight: 400,});
</script>
<script type="text/javascript">

    function test() {
        var vals = $("select[name='qtype_id']").val();
        $("#q_num").hide();
        for (var i = 1; i < "7"; i++) {
            var v = "q_type" + vals;

            if (i == vals) {

                $("#q_type" + i).show();

            } else {
                $("#q_type" + i).hide();
            }
            if (vals == "1" || vals == "2") {

                var test = document.getElementById('q_num');
                $("#q_num").show();
                $(".selector").val("");


            }
        }
    }
    function changeAns() {
        var vals = $("select[name='qnum']").val();
        var type = $("select[name='qtype_id']").val();
        var p = document.getElementById('q_type' + type);
        var childs = p.childNodes;

        for (var i = childs.length - 1; i >= 0; i--) {
            p.removeChild(childs[i]);
        }
        var arr = ["A", "B", "C", "D", "E", "F"]
        for (var i = 0; i < vals; i++) {
            var input = document.createElement("input");
            input.setAttribute("type", "text");
            input.setAttribute("name", "q_type" + type + "." + arr[i]);
            input.setAttribute("class", "input-text");
            var br = document.createElement("br");
            var label = document.createElement("laber");
            label.innerText = arr[i] + ":";
            p.appendChild(label);
            p.appendChild(input);
            p.appendChild(br);

        }

    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
{include file="public/footer"}